
<form class="layui-form" action="" lay-filter="svrPv">
	<div class="layuimini-main">
		<div class="layui-form layuimini-form">
			<!-- <input type="hidden" name="type" value="0" />
			<div class="layui-form-item">
				<label class="layui-form-label required">设备自编号</label>
				<div class="layui-input-block">
					<input type="text" name="position" lay-verify="required"
						lay-reqtext="不能为空,长度小于30个字" maxLength='30'
						placeholder="服务商的自编号 如:房间号 服务厅 " value="" class="layui-input">
				</div>
			</div>-->
			<div class="layui-form-item">
				<label class="layui-form-label required">型号</label>
				<div class="layui-input-block">
					<input type="text" name="model" maxLength='12'
						placeholder="不能为空,长度小于12个字"  lay-verify="required"
						value="" class="layui-input">
					<input type="hidden" name="status" value="1" />
					<input type="hidden" name="id" value="1" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label required">批次</label>
				<div class="layui-input-block">
					<input type="text" name="batch" maxLength='12'
						placeholder="不能为空,长度小于12个字"  lay-verify="required"
						value="" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-normal" lay-submit
						lay-filter="saveBtn">确认保存</button>
				</div>
			</div>
		</div>
	</div>
</form>

<script>
    layui.use(['form', 'table','common'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            layarea = layui.layarea,
            //data = layui.data,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        //表单初始赋值,
        form.val("svrPv", window.svrInitData[0])
 		form.render();  
        
        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;		    
 		     
         //监听提交
        form.on('submit(saveBtn)', function (data) {
        	$.ajax({
				url: "/device",
				type: 'post',
				async: false,
				data : JSON.stringify(data.field),//要转换为字符格式
				dataType: 'json',
				contentType:"application/json",
				success: function(data) {
					window.svrInitData= data.obj;
					//console.log(data.obj);
					window.isSubmit=true;
					// 关闭弹出层
           			layer.close(index);
            		layer.close(parentIndex);
				}
			});
            return false;
        });
     //初始化选择框    
	layui.common.initSelect();
    });
</script>